package com.igeekhome.ccs.controller;

import com.igeekhome.ccs.biz.ICsCustomerBiz;
import com.igeekhome.ccs.biz.IJobBiz;

import com.igeekhome.ccs.entity.CsCustomer;
import com.igeekhome.ccs.entity.Job;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/job")
public class JobController {
    //工单页面
    @Autowired
    IJobBiz iJobBiz;
    @Autowired
    ICsCustomerBiz iCsCustomerbiz;

    /**
     *显示工单
     */
    @RequestMapping("select")
    public @ResponseBody
    List<Job> select(String status, int priority, int type, String channel, int groupId, int customerId, Date createTime) {
        Job jb = new Job();
        jb.setJobId(1);
        jb.setStatus(status);
        jb.setPriority(priority);
        jb.setJobSortId(type);
        jb.setChannel(channel);
        jb.setCustomerId(customerId);
        jb.setCreateTime(createTime);
        return iJobBiz.select(jb);
    }


    /**
     *接单
     */
    @RequestMapping("/save")
    public @ResponseBody
    String save(@RequestBody Map<String,Integer> map)  {
        CsCustomer csc=new CsCustomer();
        csc.setCsId(map.get("csId"));
        csc.setCustomerId(map.get("customerId"));
        iCsCustomerbiz.save(csc);
        return "ok";
    }
    /**
     * 新建工单
     */
    @RequestMapping("newjob")
    public @ResponseBody
    String newjob(int jobId,String jobSort,String title, String content,int sponsorCsId, int priority, int groupId,int csId,int customerId){
        Job jb=new Job();
        jb.setJobId(jobId);
        jb.setTitle(title);
        jb.setContent(content);
        jb.setSponsorCsId(sponsorCsId);
        jb.setPriority(priority);
        jb.setCsId(csId);
        jb.setCustomerId(customerId);
        return null;
    }
}